#include <bits/stdc++.h>

using namespace std;

class Solution
{
public:
    void moveZeroes(vector<int> &nums)
    {
        int l = 0, r = 0;
        while (true)
        {
            while (l < nums.size() && nums[l] != 0)
            {
                ++l;
            }
            r = l;
            while (r < nums.size() && nums[r] == 0)
            {
                ++r;
            }
            if (r >= nums.size())
            {
                break;
            }
            swap(nums[l], nums[r]);
        }
    }
};